package com.kikikeji;

import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.text.TextUtils;

import com.kikikeji.weizhuo.activity.core.ActivityManageIntf;
import com.kikikeji.weizhuo.activity.core.ActivityStack;
import com.kikikeji.weizhuo.activity.core.ActivityStatusIntf;

/**
 * Created by zhang on 2016/12/4.
 */

public class WeiZhuoApplication extends Application implements ActivityManageIntf {

    private static WeiZhuoApplication mApplication;

    private static Context mApplicationContext;

    public static WeiZhuoApplication getInstance() {
        return mApplication;
    }

    public static Context getContext() {
        return mApplicationContext;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        synchronized(WeiZhuoApplication.this) {
            mApplicationContext = getApplicationContext();
            mApplication = this;
        }

        WeiZhuo.getInstance();
    }

    @Override
    public void setCurActivity(Activity act) {
        WeiZhuo.getInstance().setCurActivity(act);
    }

    @Override
    public ActivityStatusIntf getActivityStatusHelper() {
        return WeiZhuo.getInstance().getActivityStatusManager();
    }

    @Override
    public ActivityStack getActivityStack() {
        return WeiZhuo.getInstance().getAppCache().getActivityStack();
    }

    @Override
    public boolean hasRootActivity() {
        return !TextUtils.isEmpty(WeiZhuo.getInstance().getRootActivity());
    }
}
